package threads;

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;

import app.AppGlobals;

public class RunGameThread extends Thread implements Runnable {

	private String args;
	public RunGameThread(String args){
		this.args = args;
	}
	@Override
	public void run() {
	   	final String args = this.args;
    	//EventQueue.invokeLater(new Runnable() {
    		//public void run() {
    			try {
    				File file = new File(AppGlobals.launcherConfig.launcherDir + "//devpro.dll");
    				if(!file.exists()) return;
    				ProcessBuilder pb = new ProcessBuilder(AppGlobals.launcherConfig.launcherDir + "//devpro.dll", args);
    				Process p = null;
    				pb.directory(new File(AppGlobals.launcherConfig.launcherDir));
    				p = pb.start();
    				InputStream is = p.getInputStream();
    				InputStreamReader isr = new InputStreamReader(is);
    				BufferedReader br = new BufferedReader(isr);
    				String line;

    				while ((line = br.readLine()) != null) {
    					System.out.println(line);
    				}
    			} catch (IOException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			}
    		}
    	//});

	//}

}
